<%--
  Created by IntelliJ IDEA.
  User: KangFaWei
  Date: 2019/6/26
  Time: 8:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="/web/inc/header" />
 <section>
    <div class="wrap">
        <div id="seach">
            <div id="logo"><a href="http://fenlicx.qinglab.cn" title="垃圾分类查询">分类查询</a></div>
        </div>
        <form id="newForm" class="article" action="<%=path%>/web/question/insert" method="post">
            <div class="title">
                <h1>垃圾分类提问</h1>
            </div>
            <div class="publish">
                <dl>
                    <dt>分类</dt>
                    <dd>
                        <select name="garbageType.id">
                            <option selected value="">全部</option>
                            <c:forEach items="${requestScope.garbageTypes}" var="garbageType">
                                <option value="${garbageType.id}">${garbageType.title}</option>
                            </c:forEach>
                        </select>
                    </dd>
                </dl>
                <dl>
                    <dt>材质</dt>
                    <dd>
                        <select id="parent-texture">
                            <option selected value="">全部</option>
                            <c:forEach items="${requestScope.textures}" var="texture">
                                <option value="${texture.id}">${texture.title}</option>
                            </c:forEach>
                        </select>
                        <select name="texture.id" id="next-texture">
                            <option value="">全部</option>
                        </select>
                    </dd>
                </dl>
                <dl>
                    <dt>问题</dt>
                    <dd>
                        <input name="title" type="text">
                    </dd>
                </dl>
                <dl>
                    <dt>详情</dt>
                    <dd>
                        <textarea class="write-content" id="content" name="content" cols="" rows=""></textarea>
                        <div id="error-content" style="color: #FF0000"></div>
                    </dd>
                </dl>
                <div class="submit">
                    <input type="button" id="subton" value="提交">
                    <input type="reset" id="submit2" value="重置">
                </div>
            </div>
        </form>
    </div>
</section>
<script src="<%=path%>/static/js/jquery-3.3.1.min.js"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="<%=path%>/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="<%=path%>/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('content',{
        toolbars:[
            [
                'bold',//加粗
                'italic',//斜体
                'superscript', //上标
                'subscript', //下标
                'indent', //首行缩进
                'simpleupload', //单图上传
                'link', //超链接
            ]
        ]
    });
    ue.ready(function () {
       ue.setHeight(200);
   })
</script>
<script>
    $(function () {
        $("#subton").click(function () {
            var content = ue.getContentTxt();
            if(content.length>200){
                $("#error-content").html("文本太长，请重新输入");
                return;
            }
            $("#newForm").submit();
        })

        $("#parent-texture").change(function () {
            $("#next-texture").empty();
            var textureId=$(this).val();
            $.post("<%=path%>/web/question/nextTextureData",
                {textureId:textureId},
                function (mes){
                    $("#next-texture").html(mes);
                }
            )
        })
    })
</script>

<jsp:include page="/web/inc/footer" />

